package com.xspace.android.xafcommon.been;

import com.xspace.android.xafcommon.util.DownloadManager;

import java.io.File;

/**
 * 封装的是下载任务相关的数据，包括标识，进度，状态，文件保存路径等
 *
 * @author Administrator
 */
public class DownloadInfo {


    private String appId;// 下载任务的唯一标识
    private int state;// 下载状态
    private long currentLength;// 已经下载的长度
    private String downloadUrl;// 下载地址
    private String path;// apk文件的保存的绝对路径
    private String version;
    private String suffix;

    /**
     * 使用AppInfo创建DownloadInfo
     *
     * @return
     */
    public static DownloadInfo create(AppInfoBean appInfo) {
        DownloadInfo downloadInfo = new DownloadInfo();
        downloadInfo.setDownloadUrl(appInfo.url);
        downloadInfo.setAppId(appInfo.app_id);
        downloadInfo.setState(DownloadManager.STATE_NONE);// 初始化状态
        downloadInfo.setCurrentLength(0);
        downloadInfo.setVersion(appInfo.version);

        // /mnt/sdcard/包名/download/有缘网.apk
        downloadInfo.setPath(DownloadManager.DOWNLOAD_DIR + File.separator
                + appInfo.version + ".apk");

        return downloadInfo;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public long getCurrentLength() {
        return currentLength;
    }

    public void setCurrentLength(long currentLength) {
        this.currentLength = currentLength;
    }

    public String getDownloadUrl() {
        return downloadUrl;
    }

    public void setDownloadUrl(String downloadUrl) {
        this.downloadUrl = downloadUrl;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getSuffix() {
        return suffix;
    }

    public void setSuffix(String suffix) {
        this.suffix = suffix;
    }
}
